package com.slowfly.rule.engine.component;


import com.slowfly.rule.engine.service.IDecisionService;
import com.slowfly.rule.engine.service.IRuleService;
import com.slowfly.rule.engine.service.ISceneService;
import com.slowfly.rule.engine.service.IStrategyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时任务逻辑
 */
@Slf4j
@Component
public class TasksComponent {

    @Autowired
    private ISceneService sceneService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IRuleService ruleService;
    @Autowired
    private IDecisionService decisionService;

    /**
     * 定时执行
     */
    @Scheduled(initialDelay = 300000, fixedRate = 600000)
    public void reloadCache() {
        sceneService.setCache();
        strategyService.setCache();
        ruleService.setCache();
        decisionService.setCache();
        log.info("reload cache success");
    }
}
